package com.ugood.utils;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * @Description: 谁看过我时间显示
 * @Author: org
 * @CreateDate: 2018/10/26 15:56
 */
public class TimeLookUtil {


    public static String calculationTimeShow(Date date){
        //Date nowDate = new Date();
        LocalDateTime now = LocalDateTime.now();
        //获取昨日localdatetime
        LocalDateTime cl = DateUtils.dateConvertToLocalDateTime(date);
        String nowStr = DateUtils.format_ymd.format(now);
        String yesterdayStr = DateUtils.format_ymd.format(now.minusDays(1));
        String cStr = DateUtils.format_ymd.format(cl);
        if(nowStr.equals(cStr)){
            return "今天";
        }
        //判断是否是昨天
        if(yesterdayStr.equals(cStr)){
            return "昨天";
        }
        //判断是否是今年
        if(now.getYear() == cl.getYear()){
            //format_md
            return DateUtils.format_md.format(cl);
        }else{
            //format_ymd
            return  cStr;
        }
    }

}
